#define _CRT_SECURE_NO_WARNINGS 1
#pragma warning(disable:4996)
#include<stdio.h>

int main(){
    FILE* p = fopen("test.txt", "r");
    if (p == NULL) {
        perror("fopen test");
        return 1;
    }
    FILE* p2 = fopen("copy.txt", "w");
    if (p2 == NULL) {
        perror("fopen copy");
        fclose(p);
        return 1;
    }
    int ch = 0;
    while ((ch=fgetc(p)) != EOF) {
        fputc(ch, p2);
    }
    fclose(p);
    fclose(p2);
    p = NULL;
    p2= NULL;
    return 0;
}